﻿using System;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using Sinacor.UI.Bovespa.Movimento.Communication.Bovespa.Calendario.Calendario;

namespace Sinacor.UI.Bovespa.Movimento.Communication
{
    /// <summary>
    /// 
    /// </summary>
    public class Calendario : BaseCommunication
    {
        #region Construtor

        public Calendario(SessionInformation session) : base(session) { }

        #endregion

        #region Métodos Públicos

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Model.DataAtual ObterDataAtual()
        {
            Model.DataAtual dataAtual = new Model.DataAtual();
            try
            {
                using (ServiceInstance<ICalendario> serviceManager = new ServiceInstance<ICalendario>())
                {
                    ICalendario servico = serviceManager.TryGetInstance(this.Session);
                    dataAtual = Translator.DataContractToModel.Calendario.ToDataAtual(servico.ObterDataAtual());
                }
            }
            catch (Exception ex)
            {
                HandleFault(ex);                
            }
            return dataAtual;
        }

        #endregion
    }
}
